#define SPECIES 28
#define REACTIONS 46
#define VECTORSIZE 16
#define HISTSIZE 10
#define HEAPSIZE 100
#define BINS 32
#define SEED 42
#define TIME 350 
#define LIFETIME atoi(argv[2])
#define MFACTOR 10
#define MI 0.0
#define LOAD 0
#define LOADPATH "Generation.h"
#define SAVEPATH "D:\\Dropbox\\Craggz\\serial\\%2d_Generation.h"


//10 days
//#define STEPCOUNT 18000*10 

//17 days
#define STEPCOUNT 18000*17


#define INDMAX 70
//#define INDMAX 7

#define ERRF 10000

#define IND_0  0
#define IND_PC 1
#define IND_EC 2

//static float SIGMA = 0.85f;
//static float SIGMA = 1.0f;
static float SIGMA = 1.0;
static float MDELTA = 1.00f;
static float MUTATION = (float)(1.0/VECTORSIZE);
static int MUTATIONCOUNT = 0;
static int MUTATIONSUCCESS = 0;

extern FILE *fp;
#define OUTPATH "D:\\Dropbox\\Craggz\\Out\\log"
#define CUMPATH "D:\\Dropbox\\Craggz\\Out\\cum"

struct heapElementStruct{
	float fitness;
	float oldfitness;
	float vector[VECTORSIZE];
	float errorbfp[HISTSIZE];
	float errormct[HISTSIZE];
	int mutCount;
	int mutSuccess;
	int mutEvents;
	int mutCum;
	int address;
	short mutClone;

};
typedef struct heapElementStruct heapElement;

struct heapStruct{
	heapElement *elementArray[HEAPSIZE+1];
  int vectorSigmaIdx[VECTORSIZE];
  float vectorSigma[VECTORSIZE];
  float vectorMeans[VECTORSIZE];
};
typedef struct heapStruct heap;

struct heapStogramStruct{
	int countbfp[BINS];
	int countmct[BINS];
	int maxbfp;
	int maxmct;
};
typedef struct heapStogramStruct heapStogram;

float heapGauss(float, float);

void heapElementInit(heapElement *,int);
void heapElementMutate(heapElement *);
void heapMutationControl();
void heapElementFitness(heapElement *);
void heapElementCrossover(heapElement *, heapElement *, heapElement *);
void heapElementCrossoverUni(heapElement *, heapElement *, heapElement *);
void heapElementCrossoverAsex(heapElement *, heapElement *, heapElement *);
void heapMutateMoga(heap *);

void heapPrintElement(heapElement *);
void heapPrint(heap *);

void heapIfy(heap *);
void heapBuild(heap *);
void heapSort(heap * );


void heapLoad(heap *);
void heapSave(heap *, int);
